package com.simp.app.presenter.impl;
import java.util.List;
import com.simp.app.model.FindItemsInteractor;
import com.simp.app.model.OnFinishedListener;
import com.simp.app.model.impl.FindItemsInteractorImpl;
import com.simp.app.presenter.MainPresenter;
import com.simp.app.view.MainView;

public class MainPresenterImpl implements MainPresenter, OnFinishedListener {

    private MainView mainView;
    private FindItemsInteractor findItemsInteractor;

    public MainPresenterImpl(MainView mainView) {
        this.mainView = mainView;
        findItemsInteractor = new FindItemsInteractorImpl();
    }

	@Override
	public void onResume() {
        mainView.showProgress();
        findItemsInteractor.findItems(this);
    }

    @Override public void onItemClicked(int position) {
        mainView.showMessage(String.format("Position %d clicked", position + 1));
    }

    @Override public void onFinished(List<String> items) {
        mainView.setItems(items);
        mainView.hideProgress();
    }
}
